<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../assets/css/base.css">
    <style>
        .box{
            width: 200px;
            height: 200px;
            background-color: #ccc;
        }
    </style>
</head>
<body>
    <div id="app">
        <pre v-pre class="note" >
        Vue2.6^ 版本提供v-on新语法，完成动态事件绑定个取消操作
        语法：v-on:[数据仓库变量].修饰符……="取值"
        </pre>
        <input type="text" v-on:[ename]="printInputValue($event)">
        <input type="button" value="input<=>change" @click=" ename=(ename=='input'?'change':'input') " >
        <input type="button" value="删除事件" @click=" ename='' ">
        <hr>
        <input type="text" placeholder="请输入验证码">
        <!-- 动态事件绑定时，[] 内部的变量名不支持大写 -->
        <!-- <input type="button" value="发送验证码" @[evetname]="sendCode()"> -->
        <button type="button"  @[evetname]="sendCode()">发送验证码({{ num }})</button>
    </div>
    <script type="module">
        
        import { createApp } from "../assets/vue3/vue.esm-browser.js";
        createApp({
            data(){
                return {
                   ename:"input",
                   evetname:"click",
                   num:60
                }
            },
            methods:{
                printInputValue(e){
                    console.log(e.target.value)
                },
                sendCode(){
                    console.log( Math.floor( Math.random()*10000 ) );
                    this.evetname = "";
                    // setTimeout(() => {
                    //     this.evetname = "click";
                    // }, 6000);
                    let timer = setInterval(() => {
                        this.num = this.num-1;
                        if(this.num<=0){
                            this.evetname = "click";
                            this.num = 60;
                            clearInterval(timer)
                        }
                    }, 1000);
                }
            }
        }).mount("#app");
    </script>
</body>
</html>